package com.ccoffers.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import com.ccoffers.model.cardinfo.CreditCardCompany;
import com.ccoffers.service.impl.CRUDServiceImpl;

@Controller
@RequestMapping(value="/companyName")
public class CreditCardCompanyAdminController {
	@Autowired
	private CRUDServiceImpl<CreditCardCompany> creditCardCompanyService;
	
	@RequestMapping(value="/add")
	public String addCreditCardCompany(@RequestParam("companyName") String companyName, Model model){
		CreditCardCompany creditCardType = new CreditCardCompany();
		creditCardType.setCompanyName(companyName);
		creditCardCompanyService.update(creditCardType);
		return "redirect:/internal/admin";
	}
	
	@RequestMapping(value="/delete")
	public String deleteCreditCardCompany(@RequestParam("id") Long id, Model model){
		creditCardCompanyService.delete(creditCardCompanyService.retrieve(CreditCardCompany.class, id));
		return "redirect:/internal/admin";
	}
	
}
